#include <iostream>

using namespace std;

class B0
{
public:
	virtual void display()
	{
		cout << " B0 :: display() " << endl;
	}
};

class B1:public B0
{
public:
	void display()
	{
		cout << " B1 :: display() " << endl;	
	}
};

class D1:public B1
{
public:
	void display()
	{
		cout << " D1 :: display() " << endl;
	}
};

void fun(B0 *ptr)
{
	ptr->display();
}

int main()
{
	B0 b0, *p;
	B1 bl;
	D1 dl;

	p = &b0;
	fun(p);

	p = &bl;
	fun(p);

	p = &dl;
	fun(p);

	return 0;
}
